<!--
 * @Descripttion:
 * @version:
 * @Author: ybac
 * @Date: 2023-03-14 14:50:17
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-06-08 16:28:41
-->
<template>
  <a-config-provider :locale="locale" :transformCellText="({ text, column, record, index }) => transformCellText(text, column, record, index)">
    <div id="app" @contextmenu.prevent="">
      <router-view />
    </div>
  </a-config-provider>
</template>
<script>
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import enquireScreen from '@/utils/device'
import {USER_INFO} from '@/store/mutation-types'
export default {
  data() {
    return {
      locale: zhCN,
    }
  },
  created() {
    localStorage.setItem('specialRoute', 'false')
    localStorage.setItem('specialFirstMenu', '')
    this.remenberLogin()
    let that = this
    enquireScreen((deviceType) => {
      // tablet
      if (deviceType === 0) {
        that.$store.commit('TOGGLE_DEVICE', 'mobile')
        that.$store.dispatch('setSidebar', false)
      }
      // mobile
      else if (deviceType === 1) {
        that.$store.commit('TOGGLE_DEVICE', 'mobile')
        that.$store.dispatch('setSidebar', false)
      } else {
        that.$store.commit('TOGGLE_DEVICE', 'desktop')
        that.$store.dispatch('setSidebar', true)
      }
    })
  },
  methods: {
    remenberLogin() {
      /* 如果localStorage内的rememberMe存在且值为false，并且sessionStorage内不存在rememberMe，说明浏览器已经关闭过且不是记住登录状态，立即退出登录 */
      let lsRememberMe = this.$ls.get(USER_INFO) && this.$ls.get(USER_INFO).rememberMe
      let ssRememberMe = sessionStorage.getItem('rememberMe')
      if (lsRememberMe == 'false' && !ssRememberMe) {
        this.$store.dispatch('Logout').then(() => { })
      }
    },
    transformCellText(text) {
      if (!!text || text === 0) {
        return text
      } else {
        return '-'
      }
    },
  },
}
</script>
<style>
#app {
  height: 100%;
}
body {
  height: 100vh !important;
  /* overflow: hidden !important; */
  overflow-y: scroll !important;
}
</style>
